namespace Game.Component.Character
{
	public class CharacterAnimator
	{
		public enum AnimName
		{
			Idle = 0,
			Sit = 1,
			LieLeft = 2,
			LieRight = 3,
			LieCenter = 4
		}

		private Hand leftHand;

		private Hand rightHand;

		private Leg leftLeg;

		private Leg rightLeg;

		public AnimName animName;

		public CharacterAnimator(Hand leftHand, Hand rightHand, Leg leftLeg, Leg rightLeg)
		{
			this.leftHand = leftHand;
			this.rightHand = rightHand;
			this.leftLeg = leftLeg;
			this.rightLeg = rightLeg;
		}

		public void ChangeAnimation(AnimName val)
		{
			if (animName != val)
			{
				animName = val;
				if (animName == AnimName.Idle)
				{
					leftLeg.ChangeState(Leg.State.Default);
					rightLeg.ChangeState(Leg.State.Default);
					leftHand.ChangeState(Hand.State.Default);
					rightHand.ChangeState(Hand.State.Default);
				}
				else if (animName == AnimName.Sit)
				{
					leftLeg.ChangeState(Leg.State.Sit);
					rightLeg.ChangeState(Leg.State.Sit);
					leftHand.ChangeState(Hand.State.Default);
					rightHand.ChangeState(Hand.State.Default);
				}
				else if (animName == AnimName.LieLeft)
				{
					leftLeg.ChangeState(Leg.State.LieLeft);
					rightLeg.ChangeState(Leg.State.LieLeft);
					leftHand.ChangeState(Hand.State.LieLeft);
					rightHand.ChangeState(Hand.State.LieLeft);
				}
				else if (animName == AnimName.LieRight)
				{
					leftLeg.ChangeState(Leg.State.LieRight);
					rightLeg.ChangeState(Leg.State.LieRight);
					leftHand.ChangeState(Hand.State.LieRight);
					rightHand.ChangeState(Hand.State.LieRight);
				}
				else if (animName == AnimName.LieCenter)
				{
					leftLeg.ChangeState(Leg.State.Default);
					rightLeg.ChangeState(Leg.State.Default);
					leftHand.ChangeState(Hand.State.Default);
					rightHand.ChangeState(Hand.State.Default);
				}
			}
		}

		public void AddPower(int dir, float val)
		{
			if (animName == AnimName.Idle)
			{
				switch (dir)
				{
				case 0:
					leftHand.AddUpPower(val);
					rightHand.AddUpPower(val);
					break;
				case 1:
					leftHand.AddDownPower(val);
					rightHand.AddUpPower(val);
					leftLeg.AddDownPower(val);
					rightLeg.AddUpPower(val);
					break;
				case 2:
					leftHand.AddUpPower(val);
					rightHand.AddDownPower(val);
					leftLeg.AddUpPower(val);
					rightLeg.AddDownPower(val);
					break;
				}
			}
		}
	}
}
